package com.jy.api.domain;

import com.jy.api.util.UuidUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by xiaohua on 2018/12/1.
 */


@Entity
@Data
@NoArgsConstructor
public class CallTran {

    @Id
    @Column(length = 50)
    private String id;

    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date addTime;

    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;

    private String refCode;

    private String storeName;

    private double amount;

    private Date payTime;

    private String channel;

    private String storeId;

    private String productId;

    private String productName;

    private String picture;

    @Enumerated(EnumType.STRING)
    private OrderStatus status;

    private int count;


    public CallTran(Store store, Product product) {
        this.id = UuidUtil.getUuid();
        this.refCode = store.getReferralCode();
        this.storeName = store.getName();
        this.amount = product.getSalesPrice();
        this.storeId = store.getId();
        this.productId = product.getId();
        this.productName = product.getName();
        this.picture = product.getImageURL();
        this.status = OrderStatus.INIT;
        this.count = 1;
    }
}
